Source:NetHack 3.2.0/system.h
Below is the full text to system.h from the source code of NetHack 3.2.0. To link to a particular line, write [[NetHack 3.2.0/system.h#line123]], for example. Warning! This is the source code from an old release. For the latest release, see Source code 1. /* SCCS Id: @(#)system.h 3.2 96/03/18 */ 2. /* Copyright © Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3. /* NetHack may be freely redistributed. See license for details. */ 4. 5. #ifndef SYSTEM_H 6. #define SYSTEM_H 7. 8. #ifndef __GO32__ /* djgpp compiler for msdos */ 9. 10. #define E extern 11. 12. /* some old may not define off_t and size_t; if your system is 13. * one of these, define them by hand below 14. */ 15. #if (defined(VMS) && !defined(__GNUC__)) || defined(MAC) 16. #include 17. #else 18. # ifndef AMIGA 19. #include 20. # endif 21. #endif 22. 23. #if (defined(MICRO) && !defined(TOS)) || defined(ANCIENT_VAXC) 24. # if !defined(_SIZE_T) && !defined(__size_t) /* __size_t for CSet/2 */ 25. # define _SIZE_T 26. # if !((defined(MSDOS) || defined(OS2)) && defined(_SIZE_T_DEFINED)) /* MSC 5.1 */ 27. typedef unsigned int size_t; 28. # endif 29. # endif 30. #endif /* MICRO && !TOS */ 31. 32. #if defined(__TURBOC__) || defined(MAC) 33. #include /* time_t is not in */ 34. #endif 35. #if defined(ULTRIX) && !(defined(ULTRIX_PROTO) || defined(NHSTDC)) 36. /* The Ultrix v3.0 seems to be very wrong. */ 37. # define time_t long 38. #endif 39. 40. #if defined(ULTRIX) || defined(VMS) 41. # define off_t long 42. #endif 43. #if defined(AZTEC) || defined(THINKC4) || defined(__TURBOC__) 44. typedef long off_t; 45. #endif 46. 47. #endif /* __GO32__ */ 48. 49. /* You may want to change this to fit your system, as this is almost 50. * impossible to get right automatically. 51. * This is the type of signal handling functions. 52. */ 53. #if defined(_MSC_VER) || defined(__TURBOC__) || defined(WIN32) 54. # define SIG_RET_TYPE void (__cdecl *)(int) 55. #endif 56. #ifndef SIG_RET_TYPE 57. # if defined(NHSTDC) || defined(POSIX_TYPES) || defined(OS2) || defined(__DECC) 58. # define SIG_RET_TYPE void (*)() 59. # endif 60. #endif 61. #ifndef SIG_RET_TYPE 62. # if defined(ULTRIX) || defined(SUNOS4) || defined(SVR3) || defined(SVR4) 63. /* SVR3 is defined automatically by some systems */ 64. # define SIG_RET_TYPE void (*)() 65. # endif 66. #endif 67. #ifndef SIG_RET_TYPE /* BSD, SIII, SVR2 and earlier, Sun3.5 and earlier */ 68. # define SIG_RET_TYPE int (*)() 69. #endif 70. 71. #ifndef __GO32__ 72. 73. #if defined(BSD) || defined(ULTRIX) || defined(RANDOM) 74. # ifdef random 75. # undef random 76. # endif 77. E long NDECL(random); 78. # if !defined(SUNOS4) || defined(RANDOM) 79. E void FDECL(srandom, (unsigned int)); 80. # else 81. # ifndef bsdi 82. E int FDECL(srandom, (unsigned int)); 83. # endif 84. # endif 85. #else 86. E long lrand48(); 87. E void srand48(); 88. #endif /* BSD || ULTRIX || RANDOM */ 89. 90. #if !defined(BSD) || defined(ultrix) 91. /* real BSD wants all these to return int */ 92. # ifndef MICRO 93. E void FDECL(exit, (int)); 94. # endif /* MICRO */ 95. /* If flex thinks that we're not __STDC__ it declares free() to return 96. int and we die. We must use __STDC__ instead of NHSTDC because 97. the former is naturally what flex tests for. */ 98. # if defined(__STDC__) || !defined(FLEX_SCANNER) 99. # ifndef OS2_CSET2 100. # ifndef MONITOR_HEAP 101. E void FDECL(free, (genericptr_t)); 102. # endif 103. # endif 104. # endif 105. #if !defined(__SASC_60) && !defined(_DCC) 106. # if defined(AMIGA) && !defined(AZTEC_50) 107. E int FDECL(perror, (const char *)); 108. # else 109. # if !(defined(ULTRIX_PROTO) && defined(__GNUC__)) 110. E void FDECL(perror, (const char *)); 111. # endif 112. # endif 113. #endif 114. #endif 115. #ifndef NeXT 116. #ifdef POSIX_TYPES 117. E void FDECL(qsort, (genericptr_t,size_t,size_t, 118. int(*)(const genericptr,const genericptr))); 119. #else 120. # if defined(BSD) || defined(ULTRIX) 121. E int qsort(); 122. # else 123. # if !defined(LATTICE) && !defined(AZTEC_50) 124. E void FDECL(qsort, (genericptr_t,size_t,size_t, 125. int(*)(const genericptr,const genericptr))); 126. # endif 127. # endif 128. #endif 129. #endif /* NeXT */ 130. 131. #ifndef __SASC_60 132. #if !defined(AZTEC_50) && !defined(__GNUC__) 133. /* may already be defined */ 134. 135. # ifdef ULTRIX 136. # ifdef ULTRIX_PROTO 137. E int FDECL(lseek, (int,off_t,int)); 138. # else 139. E long FDECL(lseek, (int,off_t,int)); 140. # endif 141. /* Ultrix 3.0 man page mistakenly says it returns an int. */ 142. E int FDECL(write, (int,char *,int)); 143. E int FDECL(link, (const char *, const char*)); 144. # else 145. # ifndef bsdi 146. E long FDECL(lseek, (int,long,int)); 147. # endif 148. # if defined(POSIX_TYPES) || defined(__TURBOC__) 149. # ifndef bsdi 150. E int FDECL(write, (int, const void *,unsigned)); 151. # endif 152. # else 153. # ifndef __MWERKS__ /* metrowerks defines write via universal headers */ 154. E int FDECL(write, (int,genericptr_t,unsigned)); 155. # endif 156. # endif 157. # endif /* ULTRIX */ 158. 159. # ifdef OS2_CSET2 /* IBM CSet/2 */ 160. E int FDECL(unlink, (char *)); 161. # else 162. E int FDECL(unlink, (const char *)); 163. # endif 164. 165. #endif /* AZTEC_50 && __GNUC__ */ 166. 167. #ifdef MAC 168. #ifndef __CONDITIONALMACROS__ /* universal headers */ 169. E int FDECL(close, (int)); /* unistd.h */ 170. E int FDECL(read, (int, char *, int)); /* unistd.h */ 171. E int FDECL(chdir, (const char *)); /* unistd.h */ 172. E char *FDECL(getcwd, (char *,int)); /* unistd.h */ 173. #endif 174. 175. E int FDECL(open, (const char *,int)); 176. #endif 177. 178. #if defined(MICRO) 179. E int FDECL(close, (int)); 180. E int FDECL(read, (int,genericptr_t,unsigned int)); 181. E int FDECL(open, (const char *,int,...)); 182. E int FDECL(dup2, (int, int)); 183. E int FDECL(setmode, (int,int)); 184. E int NDECL(kbhit); 185. # if !defined(_DCC) 186. # if defined(__TURBOC__) 187. E int FDECL(chdir, (const char *)); 188. # else 189. E int FDECL(chdir, (char *)); 190. # endif 191. E char *FDECL(getcwd, (char *,int)); 192. # endif /* !_DCC */ 193. #endif 194. 195. #ifdef ULTRIX 196. E int FDECL(close, (int)); 197. E int FDECL(atoi, (const char *)); 198. E int FDECL(chdir, (const char *)); 199. # if !defined(ULTRIX_CC20) && !defined(__GNUC__) 200. E int FDECL(chmod, (const char *,int)); 201. E mode_t FDECL(umask, (int)); 202. # endif 203. E int FDECL(read, (int,genericptr_t,unsigned)); 204. /* these aren't quite right, but this saves including lots of system files */ 205. E int FDECL(stty, (int,genericptr_t)); 206. E int FDECL(gtty, (int,genericptr_t)); 207. E int FDECL(ioctl, (int, int, char*)); 208. E int FDECL(isatty, (int)); /* 1 yes, 0 no, -1 error */ 209. #include 210. # if defined(ULTRIX_PROTO) || defined(__GNUC__) 211. E int NDECL(fork); 212. # else 213. E long NDECL(fork); 214. # endif 215. #endif /* ULTRIX */ 216. 217. #ifdef VMS 218. # ifndef abs 219. E int FDECL(abs, (int)); 220. # endif 221. E int FDECL(atexit, (void (*)(void))); 222. E int FDECL(atoi, (const char *)); 223. E int FDECL(chdir, (const char *)); 224. E int FDECL(chown, (const char *,unsigned,unsigned)); 225. # ifndef __DECC_VER /* suppress for recent DEC C */ 226. E int FDECL(chmod, (const char *,int)); 227. E int FDECL(umask, (int)); 228. # endif 229. /* #include */ 230. E int FDECL(close, (int)); 231. E int VDECL(creat, (const char *,unsigned,...)); 232. E int FDECL(delete, (const char *)); 233. E int FDECL(fstat, ( /*_ int, stat_t * _*/ )); 234. E int FDECL(isatty, (int)); /* 1 yes, 0 no, -1 error */ 235. E long FDECL(lseek, (int,long,int)); 236. E int VDECL(open, (const char *,int,unsigned,...)); 237. E int FDECL(read, (int,genericptr_t,unsigned)); 238. E int FDECL(rename, (const char *,const char *)); 239. E int FDECL(stat, ( /*_ const char *,stat_t * _*/ )); 240. E int FDECL(write, (int,const genericptr,unsigned)); 241. #endif 242. 243. #endif /* __SASC_60 */ 244. 245. /* both old & new versions of Ultrix want these, but real BSD does not */ 246. #ifdef ultrix 247. E void abort(); 248. E void bcopy(); 249. # ifdef ULTRIX 250. E int FDECL(system, (const char *)); 251. # ifndef _UNISTD_H_ 252. E int FDECL(execl, (const char *, ...)); 253. # endif 254. # endif 255. #endif 256. #ifdef MICRO 257. E void NDECL(abort); 258. E void FDECL(_exit, (int)); 259. E int FDECL(system, (const char *)); 260. #endif 261. #ifdef HPUX 262. E long NDECL(fork); 263. #endif 264. 265. #if defined(SYSV) || defined(VMS) || defined(MAC) || defined(SUNOS4) || defined(POSIX_TYPES) 266. # if defined(NHSTDC) || defined(POSIX_TYPES) || (defined(VMS) && !defined(ANCIENT_VAXC)) 267. # if !defined(_AIX32) && !(defined(SUNOS4) && defined(__STDC__)) 268. /* Solaris unbundled cc (acc) */ 269. E int FDECL(memcmp, (const void *,const void *,size_t)); 270. E void *FDECL(memcpy, (void *, const void *, size_t)); 271. E void *FDECL(memset, (void *, int, size_t)); 272. # endif 273. # else 274. # ifndef memcmp /* some systems seem to macro these back to b*() */ 275. E int memcmp(); 276. # endif 277. # ifndef memcpy 278. E char *memcpy(); 279. # endif 280. # ifndef memset 281. E char *memset(); 282. # endif 283. # endif 284. #else 285. # ifdef HPUX 286. E int FDECL(memcmp, (char *,char *,int)); 287. E void *FDECL(memcpy, (char *,char *,int)); 288. E void *FDECL(memset, (char*,int,int)); 289. # endif 290. #endif 291. 292. #if defined(MICRO) && !defined(LATTICE) 293. # if defined(TOS) && defined(__GNUC__) 294. E int FDECL(memcmp, (const void *,const void *,size_t)); 295. E void *FDECL(memcpy, (void *,const void *,size_t)); 296. E void *FDECL(memset, (void *,int,size_t)); 297. # else 298. # if defined(AZTEC_50) || defined(NHSTDC) || defined(WIN32) 299. E int FDECL(memcmp, (const void *, const void *, size_t)); 300. E void *FDECL(memcpy, (void *, const void *, size_t)); 301. E void *FDECL(memset, (void *, int, size_t)); 302. # else 303. E int FDECL(memcmp, (char *,char *,unsigned int)); 304. E char *FDECL(memcpy, (char *,char *,unsigned int)); 305. E char *FDECL(memset, (char*,int,int)); 306. # endif /* AZTEC_50 || NHSTDC */ 307. # endif /* TOS */ 308. #endif /* MICRO */ 309. 310. #if defined(BSD) && defined(ultrix) /* i.e., old versions of Ultrix */ 311. E void sleep(); 312. #endif 313. #if defined(ULTRIX) || defined(SYSV) 314. E unsigned sleep(); 315. #endif 316. #if defined(HPUX) 317. E unsigned int FDECL(sleep, (unsigned int)); 318. #endif 319. #ifdef VMS 320. E int FDECL(sleep, (unsigned)); 321. #endif 322. 323. E char *FDECL(getenv, (const char *)); 324. E char *getlogin(); 325. #ifdef HPUX 326. E long NDECL(getuid); 327. E long NDECL(getgid); 328. E long NDECL(getpid); 329. #else 330. # ifdef POSIX_TYPES 331. E pid_t NDECL(getpid); 332. E uid_t NDECL(getuid); 333. E gid_t NDECL(getgid); 334. # else 335. # ifndef getpid /* Borland C defines getpid() as a macro */ 336. E int NDECL(getpid); 337. # endif 338. # ifdef VMS 339. E int NDECL(getppid); 340. E unsigned NDECL(getuid); 341. E unsigned NDECL(getgid); 342. # endif 343. # endif 344. # if defined(ULTRIX) && !defined(_UNISTD_H_) 345. E unsigned NDECL(getuid); 346. E unsigned NDECL(getgid); 347. E int FDECL(setgid, (int)); 348. E int FDECL(setuid, (int)); 349. # endif 350. #endif 351. 352. /*# string(s).h #*/ 353. #ifndef _XtIntrinsic_h /* #includes */ 354. 355. #if (defined(ULTRIX) || defined(NeXT)) && defined(__GNUC__) 356. #include 357. #else 358. E char *FDECL(strcpy, (char *,const char *)); 359. E char *FDECL(strncpy, (char *,const char *,size_t)); 360. E char *FDECL(strcat, (char *,const char *)); 361. E char *FDECL(strncat, (char *,const char *,size_t)); 362. E char *FDECL(strpbrk, (const char *,const char *)); 363. 364. # if defined(SYSV) || defined(MICRO) || defined(MAC) || defined(VMS) || defined(HPUX) 365. E char *FDECL(strchr, (const char *,int)); 366. E char *FDECL(strrchr, (const char *,int)); 367. # else /* BSD */ 368. E char *FDECL(index, (const char *,int)); 369. E char *FDECL(rindex, (const char *,int)); 370. # endif 371. 372. E int FDECL(strcmp, (const char *,const char *)); 373. E int FDECL(strncmp, (const char *,const char *,size_t)); 374. # if defined(MICRO) || defined(MAC) || defined(VMS) || defined(POSIX_TYPES) 375. E size_t FDECL(strlen, (const char *)); 376. # else 377. # ifdef HPUX 378. E unsigned int FDECL(strlen, (char *)); 379. # else 380. # if !(defined(ULTRIX_PROTO) && defined(__GNUC__)) 381. E int FDECL(strlen, (const char *)); 382. # endif 383. # endif /* HPUX */ 384. # endif /* MICRO */ 385. #endif /* ULTRIX */ 386. 387. #endif /* !_XtIntrinsic_h_ */ 388. 389. #if defined(ULTRIX) && defined(__GNUC__) 390. E char *FDECL(index, (const char *,int)); 391. E char *FDECL(rindex, (const char *,int)); 392. #endif 393. 394. /* Old varieties of BSD have char *sprintf(). 395. * Newer varieties of BSD have int sprintf() but allow for the old char *. 396. * Several varieties of SYSV and PC systems also have int sprintf(). 397. * If your system doesn't agree with this breakdown, you may want to change 398. * this declaration, especially if your machine treats the types differently. 399. * If your system defines sprintf, et al, in stdio.h, add to the initial 400. * #if. 401. */ 402. #if defined(ULTRIX) || defined(__DECC) || defined(__SASC_60) || defined(WIN32) 403. #define SPRINTF_PROTO 404. #endif 405. #if (defined(SUNOS4) && defined(__STDC__)) || defined(_AIX32) 406. #define SPRINTF_PROTO 407. #endif 408. #if defined(TOS) || defined(AZTEC_50) || defined(__sgi) || defined(__GNUC__) 409. /* problem with prototype mismatches */ 410. #define SPRINTF_PROTO 411. #endif 412. #if defined(__MWERKS__) 413. /* Metrowerks already has a prototype for sprintf() */ 414. # define SPRINTF_PROTO 415. #endif 416. 417. #ifndef SPRINTF_PROTO 418. # if defined(POSIX_TYPES) || defined(DGUX) || defined(NeXT) || !defined(BSD) 419. E int FDECL(sprintf, (char *,const char *,...)); 420. # else 421. # define OLD_SPRINTF 422. E char *sprintf(); 423. # endif 424. #endif 425. #ifdef SPRINTF_PROTO 426. # undef SPRINTF_PROTO 427. #endif 428. 429. #ifndef __SASC_60 430. #ifdef NEED_VARARGS 431. # if defined(USE_STDARG) || defined(USE_VARARGS) 432. # if !defined(SVR4) && !defined(apollo) 433. # if !(defined(ULTRIX_PROTO) && defined(__GNUC__)) 434. # if !(defined(SUNOS4) && defined(__STDC__)) /* Solaris unbundled cc (acc) */ 435. E int FDECL(vsprintf, (char *, const char *, va_list)); 436. E int FDECL(vfprintf, (FILE *, const char *, va_list)); 437. E int FDECL(vprintf, (const char *, va_list)); 438. # endif 439. # endif 440. # endif 441. # else 442. # define vprintf printf 443. # define vfprintf fprintf 444. # define vsprintf sprintf 445. # endif 446. #endif /* NEED_VARARGS */ 447. #endif 448. 449. #endif /* __GO32__ */ 450. 451. #define Sprintf (void) sprintf 452. #define Strcat (void) strcat 453. #define Strcpy (void) strcpy 454. 455. #ifdef NEED_VARARGS 456. # define Vprintf (void) vprintf 457. # define Vfprintf (void) vfprintf 458. # define Vsprintf (void) vsprintf 459. #endif 460. 461. #ifndef __GO32__ 462. 463. #ifdef MICRO 464. E int FDECL(tgetent, (const char *,const char *)); 465. E int FDECL(tgetnum, (const char *)); 466. E int FDECL(tgetflag, (const char *)); 467. E char *FDECL(tgetstr, (const char *,char **)); 468. E char *FDECL(tgoto, (const char *,int,int)); 469. E void FDECL(tputs, (const char *,int,int (*)())); 470. #else 471. E int FDECL(tgetent, (char *,const char *)); 472. E int FDECL(tgetnum, (const char *)); 473. E int FDECL(tgetflag, (const char *)); 474. E char *FDECL(tgetstr, (const char *,char **)); 475. E char *FDECL(tgoto, (const char *,int,int)); 476. E void FDECL(tputs, (const char *,int,int (*)())); 477. #endif 478. 479. #ifdef ALLOC_C 480. E genericptr_t FDECL(malloc, (size_t)); 481. #endif 482. 483. /* time functions */ 484. 485. # ifndef LATTICE 486. # if !(defined(ULTRIX_PROTO) && defined(__GNUC__)) 487. E struct tm *FDECL(localtime, (const time_t *)); 488. # endif 489. # endif 490. 491. # if defined(ULTRIX) || defined(SYSV) || defined(MICRO) || defined(VMS) || defined(MAC) 492. E time_t FDECL(time, (time_t *)); 493. # else 494. E long FDECL(time, (time_t *)); 495. # endif /* ULTRIX */ 496. 497. #ifdef VMS 498. /* used in makedefs.c, but missing from gcc-vms's */ 499. E char *FDECL(ctime, (const time_t *)); 500. #endif 501. 502. 503. #ifdef MICRO 504. # ifdef abs 505. # undef abs 506. # endif 507. E int FDECL(abs, (int)); 508. # ifdef atoi 509. # undef atoi 510. # endif 511. E int FDECL(atoi, (const char *)); 512. #endif 513. 514. #undef E 515. 516. #endif /* __GO32__ */ 517. 518. #endif /* SYSTEM_H */ system.h